<?php

declare(strict_types=1);

namespace App\Service;

use App\Model\User as UserModel;
use App\Model\UserGroup as UserGroupModel;

class User extends BaseService
{
    // 分页列表
    public function list(array $map)
    {
        return UserModel::query()->where($map)->select('user_id', 'parent_id', 'username', 'head_img', 'nickname', 'phone', 'balance', 'status', 'created_at')->orderBy('user_id', 'desc')->paginate(10);
    }

    // 获取用户详细信息
    public function detail($user_id)
    {
        return UserModel::query()->where('user_id', $user_id)->first();
    }

    // 分页群体列表
    public function groupList(array $map)
    {
        return UserGroupModel::query()->where($map)->orderBy('id', 'desc')->paginate(10);
    }


    // 添加用户群体
    public function addUserGroup($data)
    {
        return UserGroupModel::insert($data);
    }

    // 删除用户群体
    public function deleteUserGroup($id)
    {
        return UserGroupModel::where('id', $id)->delete();
    }
}
